********************************************************************************
********************************************************************************
*Just dont call it tax! 

*13.11.2015

clear
*I: load data, this line has to be replaced!!!  ***
insheet using "C:\Users\Paetzel\Dropbox\Minimum Income\Data\dataverse\observations.csv", comma

* See LorenzPaetzelTepe_JustDontCallItATax_JEPS_DatadocFigures.r for documentation of the data

********************************************************************************




********************************************************************************
*II: Preparation of the data:

encode  sessionid, gen(sessionid_r)
gen id = subject + (sessionid_r-1)*20

*** STATA SYNTAX ***

 *** Dummy for Frame (tax frame = 1, other =0)
 encode frame, gen(frame2)
 gen tax = 0
 replace tax = 1 if frame2==2
 
 *** Dummy for calculator (yes = 1, no =0)
 gen yes_calculator = 0
 replace yes_calculator = 1 if calculator=="calc"
 
 *** Dummy for randomorder for 2 sessions with calculator
 gen random_seq_calc  = 0
 replace random_seq_calc = 1 if sessionid=="140717_0908"
 replace random_seq_calc = 1 if sessionid=="140717_1258"
 
****** Ideal

 gen ideal_tax = ideal/100 if tax ==1

 replace ideal_tax = (ideal-800) / (1700 - 800) if period==1 & tax==0
 replace ideal_tax = (ideal-100) / (1700 - 100) if period==2 & tax==0
 replace ideal_tax = (ideal-800) / (1700 - 800) if period==3 & tax==0
 replace ideal_tax = (ideal-800) / (1700 - 800) if period==4 & tax==0
 replace ideal_tax = (ideal-100) / (1700 - 100) if period==5 & tax==0
 replace ideal_tax = (ideal-800) / (1700 - 800) if period==6 & tax==0
 
 *** Last entry

 gen decision_tax = decision/100 if tax ==1

 replace decision_tax = (decision-800) / (1700 - 800) if period==1 & tax==0
 replace decision_tax = (decision-100) / (1700 - 100) if period==2 & tax==0
 replace decision_tax = (decision-800) / (1700 - 800) if period==3 & tax==0
 replace decision_tax = (decision-800) / (1700 - 800) if period==4 & tax==0
 replace decision_tax = (decision-100) / (1700 - 100) if period==5 & tax==0
 replace decision_tax = (decision-800) / (1700 - 800) if period==6 & tax==0

 *** Group decision

 gen groupdecision_tax = groupdecision/100 if tax ==1

 replace groupdecision_tax = (groupdecision-800) / (1700 - 800) if period==1 & tax==0
 replace groupdecision_tax = (groupdecision-100) / (1700 - 100) if period==2 & tax==0
 replace groupdecision_tax = (groupdecision-800) / (1700 - 800) if period==3 & tax==0
 replace groupdecision_tax = (groupdecision-800) / (1700 - 800) if period==4 & tax==0
 replace groupdecision_tax = (groupdecision-100) / (1700 - 100) if period==5 & tax==0
 replace groupdecision_tax = (groupdecision-800) / (1700 - 800) if period==6 & tax==0


 *ok_25.11
 
 *** other coding

 tab period, gen(period)

 encode  geschlecht, gen(sex)
 recode sex 1=0 2=1, gen(female)


 
 label var pol_selbstein "Left Right attitude"
 label var alter "Age"
 label var female "Female"

 encode study, gen(study_r)
 tab study_r, gen(study_sub)

 label var study_sub1 "Engineering"
 label var study_sub2 "Others"
 label var study_sub4 "Languages"
 label var study_sub5 "Economics"


 ***** 

 rename  lorr_1  LorR_1
 rename  lorr_2  LorR_2
 rename  lorr_3  LorR_3
 rename  lorr_4  LorR_4
 rename  lorr_5  LorR_5
 rename  lorr_6  LorR_6
 rename  lorr_7  LorR_7
 rename  lorr_8  LorR_8
 rename  lorr_9  LorR_9
 rename  lorr_10 LorR_10


* Classification of the four social-preference-types 
* EFF: efficiency loving
* IAV: inequality avers
* SPI: Spiteful
* ILO: inequality loving
* inconsistent decisions are automatically dropped out 
gen benevo_disad = 0
gen malevo_disad = 0
gen benevo_ad = 0
gen malevo_ad = 0

replace benevo_disad = 1 if (LorR_1==1) & (LorR_2==1) & (LorR_3==1) & (LorR_4==1) & (LorR_5==1)
replace benevo_disad = 1 if (LorR_1==2) & (LorR_2==1) & (LorR_3==1) & (LorR_4==1) & (LorR_5==1)
replace benevo_disad = 1 if (LorR_1==2) & (LorR_2==2) & (LorR_3==1) & (LorR_4==1) & (LorR_5==1)

replace malevo_disad = 1 if (LorR_1==2) & (LorR_2==2) & (LorR_3==2) & (LorR_4==1) & (LorR_5==1)
replace malevo_disad = 1 if (LorR_1==2) & (LorR_2==2) & (LorR_3==2) & (LorR_4==2) & (LorR_5==1)
replace malevo_disad = 1 if (LorR_1==2) & (LorR_2==2) & (LorR_3==2) & (LorR_4==2) & (LorR_5==2)

replace benevo_ad = 1 if (LorR_6==2) & (LorR_7==2) & (LorR_8==2) & (LorR_9==2) & (LorR_10==2)
replace benevo_ad = 1 if (LorR_6==2) & (LorR_7==2) & (LorR_8==2) & (LorR_9==2) & (LorR_10==1)
replace benevo_ad = 1 if (LorR_6==2) & (LorR_7==2) & (LorR_8==2) & (LorR_9==1) & (LorR_10==1)

replace malevo_ad = 1 if (LorR_6==2) & (LorR_7==2) & (LorR_8==1) & (LorR_9==1) & (LorR_10==1)
replace malevo_ad = 1 if (LorR_6==2) & (LorR_7==1) & (LorR_8==1) & (LorR_9==1) & (LorR_10==1)
replace malevo_ad = 1 if (LorR_6==1) & (LorR_7==1) & (LorR_8==1) & (LorR_9==1) & (LorR_10==1)

gen EFF = 0
gen IAV = 0
gen SPI = 0
gen ILO = 0

replace EFF = 1 if (benevo_disad==1) & (benevo_ad==1)
replace IAV = 1 if (malevo_disad==1) & (benevo_ad==1)
replace SPI = 1 if (malevo_disad==1) & (malevo_ad==1)
replace ILO = 1 if (benevo_disad==1) & (malevo_ad==1)

 * dummy for being egoistic, meaning always voting for the highest possible payoff
 * and being indifferent in a situation when both options yields to the same own payoff and some payoff for the other player.
 * 
gen egoistic = 0
replace egoistic = 1 if (LorR_1==2) & (LorR_2==2) & (LorR_4==1) & (LorR_5==1) & (LorR_6==2) & (LorR_7==2) & (LorR_9==1) & (LorR_10==1)


 * dummy for being rich 
capture drop d_rich
gen d_rich = 0
replace d_rich = 1 if bruttoincome > 1700 

 * dummy for being the mean
capture drop d_middle
 gen d_middle = 0
replace d_middle = 1 if bruttoincome==1700 

 * dummy for being poor
gen d_poor = 0
replace d_poor = 1 if bruttoincome < 1700 

* Right_Left
capture drop right_left
gen right_left = .
replace right_left = 0 if pol_selbstein=="0" 
replace right_left = 1 if pol_selbstein=="1" 
replace right_left = 2 if pol_selbstein=="2" 
replace right_left = 3 if pol_selbstein=="3" 
replace right_left = 4 if pol_selbstein=="4" 
replace right_left = 5 if pol_selbstein=="5" 
replace right_left = 6 if pol_selbstein=="6" 
replace right_left = 7 if pol_selbstein=="7" 
replace right_left = 8 if pol_selbstein=="8" 

capture drop r_l_tax
gen r_l_tax = right_left*tax 
********************************************************************************



********************************************************************************
*III: Statistics in the paper: 

*Paragraph in the paper:
*The means of the individually preferred tax is significantly higher in MIN
*than in TAX among treatments when periods are pooled (t-test: t = 13.467
*with p<0.001 and Mann-Whitney: z = 10.711 with p<0.001). Moreover, also
*the means of the individually preferred tax for each single distribution (period)
*is on a p<0.001 level significantly higher in frame MIN than in TAX.


 *** IDEAL TTest by Frame
 ttest ideal_tax if yes_calculator==0, by(tax)

 ttest  ideal_tax if distribution==1 & yes_calculator==0, by(tax)
 ttest  ideal_tax if distribution==2 & yes_calculator==0, by(tax)
 ttest  ideal_tax if distribution==3 & yes_calculator==0, by(tax)
 ttest  ideal_tax if distribution==4 & yes_calculator==0, by(tax)
 ttest  ideal_tax if distribution==5 & yes_calculator==0, by(tax)
 ttest  ideal_tax if distribution==6 & yes_calculator==0, by(tax)
 
 *** IDEAL Mann-Whitney by Frame
 ranksum ideal_tax if yes_calculator==0, by(tax)

 ranksum ideal_tax if distribution==1 & yes_calculator==0, by(tax)
 ranksum ideal_tax if distribution==2 & yes_calculator==0, by(tax)
 ranksum ideal_tax if distribution==3 & yes_calculator==0, by(tax)
 ranksum ideal_tax if distribution==4 & yes_calculator==0, by(tax)
 ranksum ideal_tax if distribution==5 & yes_calculator==0, by(tax)
 ranksum ideal_tax if distribution==6 & yes_calculator==0, by(tax)

 
*Paragraph in the paper:
*The means of the implemented tax is significantly higher in the MIN frame
*than in the TAX frame (pooled over all periods; t-test: t = 15.842 with p<0.001
*and Mann-Whitney: z = 11.611 with p<0.001). Moreover, also the means of
*the implemented tax rates for each single distribution (period) is at least on a
*p<0.001 level significantly higher in frame MIN than in TAX.
 
 *** group decision TTest by Frame
 ttest  decision_tax if yes_calculator==0, by(tax)

 ttest  decision_tax if distribution==1 & yes_calculator==0, by(tax)
 ttest  decision_tax if distribution==2 & yes_calculator==0, by(tax)
 ttest  decision_tax if distribution==3 & yes_calculator==0, by(tax)
 ttest  decision_tax if distribution==4 & yes_calculator==0, by(tax)
 ttest  decision_tax if distribution==5 & yes_calculator==0, by(tax)
 ttest  decision_tax if distribution==6 & yes_calculator==0, by(tax)
 
 *** group decision Mann-Whitney by Frame 
 ranksum decision_tax if yes_calculator==0, by(tax) 
 
 ranksum decision_tax if distribution==1 & yes_calculator==0, by(tax)
 ranksum decision_tax if distribution==2 & yes_calculator==0, by(tax)
 ranksum decision_tax if distribution==3 & yes_calculator==0, by(tax)
 ranksum decision_tax if distribution==4 & yes_calculator==0, by(tax)
 ranksum decision_tax if distribution==5 & yes_calculator==0, by(tax)
 ranksum decision_tax if distribution==6 & yes_calculator==0, by(tax)

 
******************************************************************
********************** REGRESSIONS Revision for JEPS *************
  
****************************
*** NEW TAB 09.11.2015 *****
****************************
xtset id distribution


*treatment effect
est clear
xtreg ideal_tax tax                                                                             if yes_calculator==0, re  vce(robust)
estimates store m1

*treatment effects and sociodemographics
xtreg ideal_tax tax female study_sub1 study_sub2 study_sub4 study_sub5                          if yes_calculator==0, re vce(robust)
estimates store m2

*treatment effects and sociodemographics and SOC PREF 
xtreg ideal_tax tax female study_sub1 study_sub2 study_sub4 study_sub5 EFF IAV ILO SPI egoistic if yes_calculator==0, re vce(robust)
estimates store m3

*treatment effects and sociodemographics and LR
xtreg ideal_tax tax female study_sub1 study_sub2 study_sub4 study_sub5 right_left               if yes_calculator==0, re vce(robust)
estimates store m4

*treatment effects and sociodemographics and LR and IA
xtreg ideal_tax tax female study_sub1 study_sub2 study_sub4 study_sub5 right_left r_l_tax       if yes_calculator==0, re vce(robust)
estimates store m5

estout m1 m2 m3 m4 m5, cells(b(star fmt(3)) se(par fmt(3)))   ///
legend label varlabels(_cons constant)               ///
starlevels( * 0.10 ** 0.05 *** 0.010) stats(chi2 N, fmt(3 0) label(Wald-chi2 N)) style(tex)


